From 6c00e171dce67db88b8888f159c4eb78396366e5 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 22 Mar 2004 13:45:33 +0000 Subject: [PATCH] bitkeeper revision 1.816 (405eedfdtQSsv_FQddod4l3qGl-RuA) xencons: new file Makefile, Xeno-HOWTO.txt, README.CD: Install an easily-accessible console terminal client program. --- .rootkeys | 1 + README.CD | 10 +++--- docs/Xeno-HOWTO.txt | 8 +++-- tools/misc/Makefile | 3 +- tools/misc/xencons | 85 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 8 deletions(-) create mode 100755 tools/misc/xencons diff --git a/.rootkeys b/.rootkeys index 9d48129acb..c6fe3694bb 100644 --- a/.rootkeys +++ b/.rootkeys @@ -64,6 +64,7 @@ 3f8bcf29ulZIC9rC4wM70H_q4s6VPg tools/misc/xen_log.c 3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/xen_nat_enable 3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README +405eedf6_nnNhFQ1I85lhCkLK6jFGA tools/misc/xencons 4056f5155QYZdsk-1fLdjsZPFTnlhg tools/misc/xensymoops.py 4022a73cEKvrYe_DVZW2JlAxobg9wg tools/nsplitd/Makefile 4022a73cKms4Oq030x2JBzUB426lAQ tools/nsplitd/nsplitd.c diff --git a/README.CD b/README.CD index 0301030c64..a387d0694e 100644 --- a/README.CD +++ b/README.CD @@ -203,11 +203,13 @@ have e.g.: xc_dom_create.py will print the local TCP port to which you should connect to perform console I/O. A suitable console client is provided -by the Python module xend.console_client: running this module from the -command line with and parameters will start a terminal -session. An alternative is to specify '-c' to xc_dom_create.py, or add +by the Python module xenctl.console_client: running this module from +the command line with and parameters will start a +terminal session. This module is also installed as /usr/bin/xencons, +from a copy in tools/misc/xencons. An alternative to manually running +a terminal client is to specify '-c' to xc_dom_create.py, or add 'auto_console=True' to the defaults file. This will cause -xc_dom_create.py to automatically become teh console terminal after +xc_dom_create.py to automatically become the console terminal after starting the domain. The 169.254.x.x network is special in that it is the 'link local' diff --git a/docs/Xeno-HOWTO.txt b/docs/Xeno-HOWTO.txt index b3ed0217bf..7f3ad7297d 100644 --- a/docs/Xeno-HOWTO.txt +++ b/docs/Xeno-HOWTO.txt @@ -265,9 +265,11 @@ to create a separate configuration file for each domain you start. xc_dom_create.py will print the local TCP port to which you should connect to perform console I/O. A suitable console client is provided -by the Python module xend.console_client: running this module from the -command line with and parameters will start a terminal -session. An alternative is to specify '-c' to xc_dom_create.py, or add +by the Python module xenctl.console_client: running this module from +the command line with and parameters will start a +terminal session. This module is also installed as /usr/bin/xencons, +from a copy in tools/misc/xencons. An alternative to manually running +a terminal client is to specify '-c' to xc_dom_create.py, or add 'auto_console=True' to the defaults file. This will cause xc_dom_create.py to automatically become teh console terminal after starting the domain. diff --git a/tools/misc/Makefile b/tools/misc/Makefile index 3db1b76fc0..c572e6d9a4 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -10,7 +10,8 @@ OBJS = $(patsubst %.c,%.o,$(SRCS)) TARGETS = xen_cpuperf -INSTALL = $(TARGETS) xen-mkdevnodes xen_nat_enable xen-clone xen_dmesg.py +INSTALL = $(TARGETS) xen-mkdevnodes xen_nat_enable xen-clone +INSTALL += xen_dmesg.py xencons all: $(TARGETS) $(MAKE) -C miniterm diff --git a/tools/misc/xencons b/tools/misc/xencons new file mode 100755 index 0000000000..b826c89dee --- /dev/null +++ b/tools/misc/xencons @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +############################################## +# Console client for Xen guest OSes +# Copyright (c) 2004, K A Fraser +############################################## + +import errno, os, signal, socket, struct, sys + +from termios import * +# Indexes into termios.tcgetattr() list. +IFLAG = 0 +OFLAG = 1 +CFLAG = 2 +LFLAG = 3 +ISPEED = 4 +OSPEED = 5 +CC = 6 + +def __child_death(signum, frame): + global stop + stop = True + +def __recv_from_sock(sock): + global stop + stop = False + while not stop: + try: + data = sock.recv(1) + os.write(1, data) + except socket.error, error: + if error[0] != errno.EINTR: + raise + os.wait() + +def __send_to_sock(sock): + while 1: + data = os.read(0,1) + if ord(data[0]) == ord(']')-64: + break + try: + sock.send(data) + except socket.error, error: + if error[0] == errno.EPIPE: + sys.exit(0) + if error[0] != errno.EINTR: + raise + sys.exit(0) + +def connect(host,port): + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, + struct.pack('ii', 0, 0)) + sock.connect((host,port)) + + oattrs = tcgetattr(0) + nattrs = tcgetattr(0) + nattrs[IFLAG] = nattrs[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON) + nattrs[OFLAG] = nattrs[OFLAG] & ~(OPOST) + nattrs[CFLAG] = nattrs[CFLAG] & ~(CSIZE | PARENB) + nattrs[CFLAG] = nattrs[CFLAG] | CS8 + nattrs[LFLAG] = nattrs[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG) + nattrs[CC][VMIN] = 1 + nattrs[CC][VTIME] = 0 + + if os.fork(): + signal.signal(signal.SIGCHLD, __child_death) + print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********" + tcsetattr(0, TCSAFLUSH, nattrs) + try: + __recv_from_sock(sock) + finally: + tcsetattr(0, TCSAFLUSH, oattrs) + print + print "************ REMOTE CONSOLE EXITED *****************" + else: + signal.signal(signal.SIGPIPE, signal.SIG_IGN) + __send_to_sock(sock) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print sys.argv[0] + " " + sys.exit(1) + connect(str(sys.argv[1]),int(sys.argv[2])) -- 2.30.2